import React, {Component} from 'react';
import {
    AppRegistry,
    StyleSheet,
    Text,
    View,
    Image
} from 'react-native';





export default class MinePage extends Component {

    render() {
        return (
            <View style={styles.container}>
                <Text>我的</Text>

                <MyTime name="李四"/>


            </View>
        );
    }
}


class MyTime extends Component {
    constructor(props) {
        super(props);
        this.state = {
            showText: true ,

            name:'张三'
        };



        // 每1000毫秒对showText状态做一次取反操作
        setInterval(() => {
            this.setState(previousState => {
                return { showText: !previousState.showText };
            });
        }, 1000);
    }

    render() {
        // 根据当前showText的值决定是否显示text内容
        let display = this.state.showText ?
            this.props.name : this.state.name;
        return (
            <Text>{display}</Text>
        );
    }
}



const styles = StyleSheet.create({
    container: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
    },
    icon:{
        width:20,
        height:20
    }
});